package com.woniu.market_stall.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.market_stall.entity.User;
import com.woniu.market_stall.mapper.UserMapper;
import com.woniu.market_stall.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    UserMapper userMapper;



    public PageInfo<UserVo> queryByPage(Integer now, Integer size, String name) {
        PageHelper.startPage(now,size);
        List<UserVo> list = userMapper.selectManagerByName(name);
        return new PageInfo<>(list);
    }

    public int removeStallByKey(Long id) {

        int i = userMapper.delByPrimaryKey(id);
        return i;
    }


    public User queryPerByKey(Integer id) {
        return userMapper.queryPerByKey(id);

    }

    public void modify(User u) {

        userMapper.updateUser(u);
    }

    public void add(UserVo userVo) {

        userMapper.insertUser(userVo);
    }

    public PageInfo<UserVo> querynameByPage(Integer now, Integer size, String name) {

        PageHelper.startPage(now,size);
        List<UserVo> list = userMapper.selectUserByName(name);
        return new PageInfo<>(list);
    }

    public List<UserVo> queryAllUser() {
        return userMapper.selectShowAllUser();
    }
}
